package com.example.myweather.tools

import android.app.Application
import android.content.Context
import android.content.res.Resources
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.media.Image

import com.example.myweather.R
import com.example.myweather.WeatherActivity

object Weather_Dict {


    fun skycon_dict(value: String): String {

        when (value) {
            "CLEAR_DAY" -> return "晴（白天）"

            "CLEAR_NIGHT" -> return "晴（夜间）"

            "PARTLY_CLOUDY_DAY" -> return "多云（白天）"

            "PARTLY_CLOUDY_NIGHT" -> return "多云（夜间）"

            "CLOUDY" -> return "阴"

            "LIGHT_HAZE" -> return "轻度雾霾"

            "MODERATE_HAZE" -> return "中度雾霾"

            "HEAVY_HAZE" -> return "重度雾霾"

            "LIGHT_RAIN" -> return "小雨"

            "MODERATE_RAIN" -> return "中雨"

            "HEAVY_RAIN" -> return "大雨"

            "STORM_RAIN" -> return "暴雨"

            "FOG" -> return "雾"

            "LIGHT_SNOW" -> return "小雪"

            "MODERATE_SNOW" -> return "中雪"

            "HEAVY_SNOW" -> return "大雪"

            "STORM_SNOW" -> return "暴雪"

            "DUST" -> return "浮尘"

            "SAND" -> return "沙尘"

            "WIND" -> return "大风"

            "THUNDER_SHOWER" -> return "雷阵雨"

            "HAIL" -> return "冰雹"

            "SLEET" -> return "雨夹雪"

            //你可以有任意数量的case语句
            else //可选
            -> return value//语句
        }
    }

    fun skycon_dictm(value: String): Bitmap {

        val bmp: Bitmap

        when (value) {
            "CLEAR_DAY" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.sunny)
                return bmp
            }

            "CLEAR_NIGHT" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.sunny_night)
                return bmp
            }

            "PARTLY_CLOUDY_DAY" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.cloudy_sunny)
                return bmp
            }

            "PARTLY_CLOUDY_NIGHT" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.cloudy_sunny_night)
                return bmp
            }

            "CLOUDY" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.cloudy)
                return bmp
            }

            "LIGHT_HAZE" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.haze)
                return bmp
            }

            "MODERATE_HAZE" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.haze)
                return bmp
            }

            "HEAVY_HAZE" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.haze)
                return bmp
            }

            "LIGHT_RAIN" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.rain_light)
                return bmp
            }

            "MODERATE_RAIN" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.rain)
                return bmp
            }

            "HEAVY_RAIN" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.rain_heavy)
                return bmp
            }

            "STORM_RAIN" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.rain_storm)
                return bmp
            }

            "FOG" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.fog)
                return bmp
            }

            "LIGHT_SNOW" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.snow_light)
                return bmp
            }

            "MODERATE_SNOW" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.snow)
                return bmp
            }

            "HEAVY_SNOW" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.snow_heavy)
                return bmp
            }

            "STORM_SNOW" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.snow_shower)
                return bmp
            }

            "DUST" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.dust)
                return bmp
            }

            "SAND" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.sandstorm)
                return bmp
            }

            "WIND" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.shower)
                return bmp
            }

            "THUNDER_SHOWER" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.thunder_shower)
                return bmp
            }

            "HAIL" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.thund_shower_hail)
                return bmp
            }

            "SLEET" -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.sleet)
                return bmp
            }
            //你可以有任意数量的case语句
            else //可选
            -> {
                bmp = BitmapFactory.decodeResource(MainApplication.context!!.getResources(), R.drawable.sunny)
                return bmp//语句
            }
        }
    }


    fun switchweek(w: Int): String {
        when (w) {
            1 -> return "一"

            2 -> return "二"

            3 -> return "三"

            4 -> return "四"

            5 -> return "五"

            6 -> return "六"

            7 -> return "日"
            else //可选
            -> return "错误"//语句
        }
    }

    fun getWindDirec(d: Double?): String {
        var d = d

        val i = (d!! / 90).toInt()
        when (i) {
            0 -> return "北偏东" + d + "度"
            1 -> {
                d = 180 - d
                return "南偏东" + d + "度"
            }
            2 -> {
                d = d - 180
                return "南偏西" + d + "度"
            }
            3 -> {
                d = 360 - d
                return "北偏西" + d + "度"
            }
            else -> return "错误"
        }

    }


}
